import React, {Component} from 'react';
import {Item} from "../Item";

type IProps = {
    toDoList: ToDo[],
    updateToDo: any,
    deleteToDo: any
}

export class ToDo {

    constructor(id: string, text: string) {
        this.id = id;
        this.text = text;
    }

    id: string;
    text: string;
    isChecked: boolean = false;
}

class ToDoList extends Component<IProps> {

    constructor(props: IProps) {
        super(props);
    }

    //高阶函数
    handleMouse = (flag: boolean) => {
        return (e: any) => {
            console.log(flag)
        }
    }

    render() {
        const {toDoList, updateToDo, deleteToDo} = this.props;
        return (
            <div>
                <ul>
                    {toDoList.map(value => {
                        return <Item key={value.id} toDo={value} updateToDo={updateToDo} deleteToDo={deleteToDo}/>
                    })}
                </ul>

            </div>
        );
    }
}

export default ToDoList;